/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PropertyRental.ejb.beans;

import PropertyRental.ejb.persistence.Owner;
import PropertyRental.ejb.persistence.Property;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Bast
 */
@Stateless
public class OwnerFacade extends AbstractFacade<Owner> {
    @PersistenceContext(unitName = "PropertyRental-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public OwnerFacade() {
        super(Owner.class);
    }

    public Owner addPropertyToOwner(Owner o, Property p){
        o.addProperty(p);
        o = em.merge(o);
        return o;
    }

}
